Two puzzles

Sayan, a colleague of mine, asked me two puzzles a few days ago. I was able to answer one of them, and could not solve the other. Here are the puzzles, first the one which I could not solve, and then the one which I could.

Capsules got mixed up

Question

There are two jars. First jar contains two capsules of type A, the other one contains two capsules of type B. Your doctor has asked you to take one type A and one type B capsule everyday, for next 2 days. The capsules are indistinguisable from each other.

However, because of a little child, the capsules got mixed up. How can you still follow doctor's instructions?

Answer after a bit of scrolling.

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Answer

Just take half of each of the four capsules on both the days!

Equal heads and tails

Question

You are blindfolded. You have 26 coins on a table, and you know that 20 of them are heads-up and other 6 are tails-up. For a given coin, you cannot tell whether it is heads-up or tails-up (by touching it or otherwise). You have to divide the coins in two groups such that each group contains equal number of tails. You are allowed to flip the coins.

Answer after a bit of scrolling.

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Answer

Divide the coins in two groups, containing 20 and 6 coins respectively. Flip all the coins in the second group. Now both the groups contain equal number of tails-up coins.

Why? If first group had $k$ tails-up coins, second group will have $6-k$ tails-up coins. Thus, second group will have $k$ heads-up coins. After flipping, second group will have $k$ tails-up coins. Value of $k$ may be anything from 0 to 6.

We can generalize it. Let's say we have $k_1 + k_2$ coins on table such that $k_1$ of them are heads-up and $k_2$ are tails-up. Now, to ensure equal number of tails-up coins in two groups, divide the coins in group of $k_1$ and $k_2$ coins, and flip the second group. Again, if first group has $k$ tails-up coins, second group has $k_2-k$ tails-up coins. Thus, it has $k$ heads-up coins, and on flipping it will have $k$ tails-up coins.